import 'package:flutter/material.dart';
import 'package:myapp/Vehicle/vehicle_page.dart';
import 'package:myapp/Destinations/destinations_page.dart';
import 'package:myapp/Activity/actvity_page.dart';
import 'package:myapp/Discover/discover_page.dart';
import 'package:myapp/More/more_page.dart';

class MainTabPage extends StatefulWidget {

  @override
  State<StatefulWidget> createState() {
    return _MainTabPage();
  }
}

class _MainTabPage extends State<MainTabPage> {

  final List<BottomNavigationBarItem> tabBarItems = [
    BottomNavigationBarItem(
      title: Text("vehicle"),
      icon: Icon(Icons.cake),
    ),
    BottomNavigationBarItem(
      title: Text("destinations"),
      icon: Icon(Icons.cake),
    ),
    BottomNavigationBarItem(
      title: Text("activity"),
      icon: Icon(Icons.cake),
    ),
    BottomNavigationBarItem(
      title: Text("discover"),
      icon: Icon(Icons.cake),
    ),
    BottomNavigationBarItem(
      title: Text("more"),
      icon: Icon(Icons.cake),
    ),
  ];

  final List<Widget> bodys = [
    VehiclePage(),
    DestinattionsPage(),
    ActivityPage(),
    DiscoverPage(),
    MorePage(),
  ];

  Widget currentPage;
  int currentIndex = 0;

  @override
  void initState() {
    currentPage = bodys[currentIndex];
    super.initState();

  }

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: Text("main tab"),
        centerTitle: true,
        leading: Text("  Hi Belli", style: TextStyle(color: Colors.black),),
        textTheme: TextTheme(title: TextStyle(fontSize: 14.0)),
        backgroundColor: Colors.white,
      ),
      body: IndexedStack(
        index: currentIndex,
        children: bodys,
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: tabBarItems,
        type: BottomNavigationBarType.fixed,
        currentIndex: currentIndex,
        onTap: (index){
          setState(() {
            this.currentIndex = index;
            this.currentPage = bodys[currentIndex];
          });
        },
      ),
    );
  }
}